﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;

namespace VictorBlaga.DocumentManagement.Helpers.Validators
{
    public static class ValidationHelper
    {
        private static readonly Regex emailRegex = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
        private static readonly Regex usernameRegex = new Regex(@"^[A-Za-z](?=[A-Za-z0-9_.]{3,31}$)[a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*$");


        public static bool IsValidUsername(string username)
        {
            bool testValid = usernameRegex.IsMatch(username);
            return testValid;
        }

        public static bool IsValidEmail(string email)
        {
            bool testValid = emailRegex.IsMatch(email);
            return testValid;
        }
    }
}